let BaseUrl = 'https://api.wjingchang.cc'
let SUCCESSCODE = 200
/**
 * request 发起网络请求
 * url 必填 请求地址
 * method 必填  请求方式GET,POST
 * postData 可选 携带参数
 * doSuccess 可选 成功回调
 * doFail 可选 错误回调
 * doComplete 可选 完成回调
 */
function request(url,method,postData, doSuccess, doFail, doComplete) {
  wx.request({
    url: url,
    method:method,
    data: postData,
    success: function(res) {
      if (typeof doSuccess == "function") {
        doSuccess(res);
      }
    },
    fail: function() {
      if (typeof doFail == "function") {
        doFail();
      }
    },
    complete: function() {
      if (typeof doComplete == "function") {
        doComplete();
      }
    }
  });
}

module.exports = {
  BaseUrl,
  request,
  SUCCESSCODE
}